/*
 * Copyright (c) 2023 Cshoo Org. All Rights Reserved.
 */

package org.cshoo.tattoo.datacenter.domain.repository;

import org.cshoo.tattoo.datacenter.domain.po.Message;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

/**
 * @author 杨翼
 * @since 1.0
 */
public interface IMessageRepository extends CrudRepository<Message, Long>  {
    /**
     * 根据编号查询message
     *
     * @param code 编号
     * @return lookup
     */
    Message findByCode(String code);

    /**
     * 分页查询message
     *
     * @param keyword 查询关键字
     * @param pageable             分页对象
     * @return lookup分页列表
     */
    @Query("SELECT message FROM Message message WHERE message.code like %:#{#keyword}% OR message.name LIKE %:#{#keyword}%")
    Page<Message> queryMessage(String keyword, Pageable pageable);
}
